package com.shruijin.wy.thread.action;

import com.shruijin.wy.thread.anno.SimpleThreadAnno;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public class SimpleAction {

    Logger LOGGER = LoggerFactory.getLogger(this.getClass());

    protected int value=100;

    @SimpleThreadAnno
    public void simpleaction(String threadName){
//        synchronized (this){
//            add(1,threadName);
//            sub(1,threadName);
//        }
        add(1,threadName);
        sub(1,threadName);
    }

    public  void add(int val,String threadName){

        LOGGER.info("{} : {} add 1",threadName,value);
        value +=val;
        LOGGER.info("{} : result {}",threadName,value);
    }

    public  void sub(int sub,String threadName){
        LOGGER.info("{} : {} sub 1",threadName,value);
        value -=sub;
        LOGGER.info("{} : result {}",threadName,value);
    }

}
